<template>
  <div class="welcome-container">
    <div class="welcome-card">
      <div class="time-display">
        <div id="showTime" class="time-text"></div>
      </div>
      <div class="greeting">
        <span class="greeting-icon">{{getTimeState()}}</span>
        <span class="greeting-text">欢迎来到北京114挂号系统管理员端</span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
// 原有JS逻辑保持不变
import { onMounted, onUnmounted } from 'vue';

const getTimeState = () => {
  const timeNow = new Date();
  const hours = timeNow.getHours();

  if (hours >= 0 && hours <= 10) return '🌞 早上好！';
  if (hours > 10 && hours <= 11) return '🌞 上午好！';
  if (hours > 11 && hours <= 13) return '🌼 中午好！';
  if (hours > 13 && hours <= 18) return '🌼 下午好！';
  if (hours > 18 && hours <= 24) return '🌙 晚上好！';
  return '👋 你好！';
}

let timer: number;

const updateTime = () => {
  const date = new Date();
  const weekDays = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
  const week = weekDays[date.getDay()];

  const ymd = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
  const hms = `${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}:${String(date.getSeconds()).padStart(2, '0')}`;

  const timeElement = document.getElementById("showTime");
  if (timeElement) {
    timeElement.innerHTML = `${ymd} &nbsp;&nbsp; ${week} &nbsp;&nbsp; ${hms}`;
  }
}

onMounted(() => {
  updateTime();
  timer = setInterval(updateTime, 1000);
});

onUnmounted(() => {
  clearInterval(timer);
});
</script>

<style scoped>
.welcome-container {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4edf9 100%);
  position: relative;
  overflow: hidden;
}

.welcome-container::before {
  content: "";
  position: absolute;
  top: -50px;
  left: -50px;
  right: -50px;
  bottom: -50px;
  background:
      radial-gradient(circle at 10% 20%, rgba(77, 145, 255, 0.05) 0%, transparent 25%),
      radial-gradient(circle at 90% 80%, rgba(66, 211, 146, 0.05) 0%, transparent 25%);
  z-index: 0;
}

.welcome-card {
  width: 85%;
  max-width: 900px;
  height: 480px;
  padding: 50px;
  border-radius: 24px;
  box-shadow:
      0 15px 35px rgba(50, 100, 200, 0.1),
      0 5px 15px rgba(0, 0, 0, 0.07);
  text-align: center;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.6);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.welcome-card:hover {
  transform: translateY(-5px);
  box-shadow:
      0 20px 40px rgba(50, 100, 200, 0.15),
      0 8px 20px rgba(0, 0, 0, 0.1);
}

.time-display {
  font-family: 'Segoe UI', 'Roboto', sans-serif;
  min-width: 380px;
  margin: 0 auto 50px;
  padding: 18px 30px;
  background: linear-gradient(to right, #2c3e50, #4a6491);
  border-radius: 16px;
  box-shadow: 0 6px 12px rgba(44, 62, 80, 0.2);
  color: white;
  position: relative;
  overflow: hidden;
}

.time-display::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(to right, #3498db, #2ecc71);
}

.time-text {
  font-size: 1.4rem;
  font-weight: 500;
  letter-spacing: 0.5px;
  display: inline-block;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.greeting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-top: 20px;
}

.greeting-icon {
  font-size: 5rem;
  margin-bottom: 25px;
  animation: float 4s ease-in-out infinite;
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.greeting-text {
  font-size: 2.8rem;
  font-weight: 700;
  color: #2c3e50;
  line-height: 1.3;
  background: linear-gradient(to right, #3498db, #2c3e50);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}

@media (max-width: 992px) {
  .greeting-text {
    font-size: 2.2rem;
  }
}

@media (max-width: 768px) {
  .welcome-card {
    width: 92%;
    padding: 40px 25px;
    height: 420px;
  }

  .greeting-text {
    font-size: 1.8rem;
  }

  .time-text {
    font-size: 1.1rem;
  }

  .time-display {
    min-width: 300px;
    padding: 15px 20px;
    margin-bottom: 40px;
  }

  .greeting-icon {
    font-size: 4rem;
    margin-bottom: 20px;
  }
}

@media (max-width: 480px) {
  .welcome-card {
    height: 380px;
    padding: 30px 20px;
    border-radius: 20px;
  }

  .greeting-text {
    font-size: 1.5rem;
  }

  .time-display {
    min-width: 260px;
    padding: 12px 15px;
  }

  .time-text {
    font-size: 0.95rem;
  }

  .greeting-icon {
    font-size: 3.5rem;
  }
}
</style>